<!--
 * @Author: yansheng 610363806@qq.com
 * @Date: 2024-07-15 23:54:39
 * @LastEditors: zhang00001 774004514@qq.com
 * @LastEditTime: 2024-08-02 17:55:21
 * @FilePath: \cell-admin\src\pages\setting\raffle\deliverGoods.vue
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
-->
<template>
  <a-drawer
    :title="'查看物流'"
    placement="right"
    :closable="true"
      :maskClosable='false'
    :keyboard='false'
    width="800"
    v-model:open="showAddDialog"
  >
    <a-timeline>
      <a-timeline-item
        v-for="item in logisticsList"
        :key="item.id"
      >
        {{ transTime(item.time) }}   {{ item.desc }}
      </a-timeline-item>
    </a-timeline>

    <a-button @click="handleCancel">取消</a-button>
  </a-drawer>
</template>

<script setup>
  import { message } from 'ant-design-vue'
  import { raffleLogistics } from '@/api/index.js'
  import { ref, defineEmits, defineExpose, defineProps, toRefs, nextTick } from 'vue'
  const emits = defineEmits([])
  const showAddDialog = ref(false)
  const logisticsList = ref([])
  const  trackingInfo=ref({
    tracking_number:'',
    phone:''
  })
   
  const getLogistics = () => {
    raffleLogistics({ tracking_number: trackingInfo.value.tracking_number, mobile: trackingInfo.value.phone }).then((res) => {
      if(res.errorCode){
        message.error(res.msg||'操作失败')
        return
      }
      logisticsList.value = res.data.info[0].logisticsTraceDetailList
    }).catch((err) => {
          message.error(err.msg)
        })
  }
const transTime=(time)=>{
  return new Date(time).toLocaleString().replace(/年|月/g, '-').replace(/日/g, ' ')
}
  const init = (tracking_number, phone) => {
    showAddDialog.value = true
    ;(trackingInfo.value.tracking_number = tracking_number), (trackingInfo.value.phone = phone)
    getLogistics()
  }

  const handleCancel = () => {
    showAddDialog.value = false
  }
  defineExpose({
    init
  })
</script>
<style scoped lang="less"></style>
